<?php
class aplikasi_role extends Base_model
{
	function __construct()
	{
		parent::__construct();
		$this->init("role_aplikasi","id_roleaplikasi");				
	}
	
	function get_in_list($id_role)
	{
		$rec = $this->get_by_role($id_role);
		$hasil = array();	
		if($rec)
		{
			foreach($rec as $row)
			{
				$hasil[] = $row->id_aplikasi;
			}
			return $hasil;
		}
		
		return FALSE;
	}
	
	function get_by_role($id_role)
	{
		$rec = $this->db->select("id_role,id_roleaplikasi,id_aplikasi,nama_aplikasi")
		            ->from($this->table_name)
					->where("id_role",$id_role)
					->get();
					
		if($rec->num_rows()>0)
		{
			return $rec->result();
		}
		return FALSE;
	}
	
	function is_exists($id_role,$id_aplikasi)
	{
		$rec = $this->db->select("id_role,id_roleaplikasi,id_aplikasi,nama_aplikasi")
		            ->from($this->table_name)
					->where("id_role",$id_role)
					->where("id_aplikasi",$id_aplikasi)
					->get();
					
		if($rec->num_rows()>0)
		{
			return TRUE;
		}
		return FALSE;
		
	}

}
?>